package com.fuxi.cloud.desreport.service.a;

import com.fuxi.cloud.desreport.dao.JimuReportLinkDao;
import com.fuxi.cloud.desreport.entity.JimuReportLink;
import com.fuxi.cloud.desreport.service.IJimuReportLinkService;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.minidao.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * a
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
@Service("jimuReportLinkServiceImpl")
public class c implements IJimuReportLinkService {
    @Autowired
    private JimuReportLinkDao linkDao;

    public c() {
    }

    @Override
    public String saveAndEdit(JimuReportLink jimuReportLink) {
        if (StringUtils.isEmpty(jimuReportLink.getId())) {
            String var2 = jimuReportLink.getId();
            JimuReportLink var3 = this.linkDao.get(var2);
            if (null == var3) {
                jimuReportLink.setId(String.valueOf(SnowflakeIdWorker.generateId()));
                this.linkDao.insert(jimuReportLink);
                return jimuReportLink.getId();
            } else {
                return jimuReportLink.getId();
            }
        } else {
            this.linkDao.update(jimuReportLink);
            return jimuReportLink.getId();
        }
    }

    @Override
    public List<JimuReportLink> queryByIds(String ids) {
        return this.linkDao.queryByIds(Arrays.asList(ids.split(",")));
    }

    @Override
    public void removeById(String id) {
        this.linkDao.deleteById(id);
    }
}

